#pragma once

#include<iostream>
#include<fstream>
#include<unordered_map>
const std::string dictname = "./dict.txt";
using std::cout;
using std::endl;
using std::string;
class Init
{
public:
    bool Split(const string&s, string &p1, string&p2)
    {
        int pos = s.find(':');
        if(pos == string::npos){
            return false;
        }
        p1 = s.substr(0,pos);
        p2 = s.substr(pos + 1);
    }
    Init()
    {
        std::ifstream in(dictname);
        if(!in.is_open())
        {
            cout << "cannt open file!\n";
            exit(0);
        }
        string line;
        while(std::getline(in,line))
        {
            std::string part1,part2;
            Split(line,part1,part2);
            mp.insert(make_pair(part1,part2));
        }
        in.close();

    }
    string operator()(const string& str)
    {
        if(mp.find(str) != mp.end())
        {
            return mp[str];
        }
        else
        {
            return "不存在!";
        }
    }
private:
    std::unordered_map<string,string> mp;
};